package editro.view.components 
{
	import flash.display.GradientType;
	import flash.display.Shape;
	import flash.display.SpreadMethod;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Matrix;
	import org.osflash.signals.Signal;
	
	/**
	 * ...
	 * @author LEEF LEE_LEAF918@163.COM_QQ969442267
	 */
	public class DockBar extends Sprite 
	{
		private var bgShape:Shape;
		private static const HEIGHT:Number = 40;
		public static const TRACEBTN:String = '6b9a2d90-91b7-45a9-9304-f3a63627654c';
		public var buttonSignal:Signal;
		public static const verticalPadding:Number = 5;
		public function DockBar() 
		{
			
		}
		
		public function init(w:int, h:int):void 
		{
			buttonSignal = new Signal(String);
			drawBgShape(w, h);
			addButtons();
		}
		
		private function addButtons():void 
		{
			var traceBtn:ColorButton = new ColorButton
			traceBtn.setLable('EXPORT');
			traceBtn.setColor(2);
			traceBtn.y = verticalPadding;
			addChild(traceBtn);
			traceBtn.addEventListener(MouseEvent.CLICK, dispatchTrace);
		}
		
		private function dispatchTrace(e:MouseEvent):void 
		{
			buttonSignal.dispatch(TRACEBTN);
		}
		
		private function drawBgShape(w:int, h:int):void 
		{
			bgShape=new Shape
			var fillType:String = GradientType.LINEAR;
			var colors:Array = [0xF0F0F0, 0xC0C0C0];
			var alphas:Array = [1, 1];
			var ratios:Array = [0x00, 0xFF];
			var matr:Matrix = new Matrix();
			matr.createGradientBox(w, HEIGHT,Math.PI/2, 0, 0);
			var spreadMethod:String = SpreadMethod.PAD;
			bgShape.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod);
			bgShape.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
			addChild(bgShape);
			//
			y = h - HEIGHT;
		}
	}
}